
#define TASK_NUM	3

void exFunc1(void)
{
	//示例任务1
}
void exFunc2(void)
{
	//示例任务2
}
void exFunc3(void)
{
	//示例任务3
}

typedef struct{

	uint8_t run;
	uint8_t TimeCount;
	uint8_t TimeReload;
	void (*TaskFunc)(void);
}Task_t;

static Task_t task[TASK_NUM] = {

	{0,0,5,exFunc1},
	{0,0,10,exFunc2},
	{0,0,500,exFunc3},
};

//假设1ms进入一次cb
void TimeCallback(void)
{
	for (int i = 0; i < TASK_NUM; ++i)
	{
		//++
		// if (!task[i].run)
		// {
		// 	task[i].TimeCount++;
		// 	if (task[i].TimeCount == task[i].TimeReload)
		// 	{
		// 		task[i].TimeCount = 0;
		// 		task[i].run = 1;
		// 	}
		// }

		//--
		if (task[i].TimeCount)
		{
			task[i].TimeCount--;
			if (task[i].TimeCount == 0)
			{
				task[i].TimeCount = task[i].TimeReload;
				task[i].run = 1;
			}
		}
	}

}

void TaskHandle()
{
	for (int i = 0; i < TASK_NUM; ++i)
	{
		if (task[i].run)
		{
			task[i].TaskFunc();
			task[i].run = 0;
		}
	}


}

void main(void)
{
	while(1)
	{

		TaskHandle();
	}


}